package com.sportsforce.client.search;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.sportsforce.client.twitter.TwitterRequest;



/** 
 * Shows a text field for the search by the Twitter user name.
 * 
 * @InProgress
 * @MainFeature 
 */

public class UserNameSearch extends HorizontalPanel {

	public UserNameSearch() {

		this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		this.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		this.setSpacing(10);

		final TextBox username = new TextBox();

		Button userButton = new Button("View Twitters");
		userButton.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {

				String url = "http://twitter.com/status/user_timeline/";

				// String username = "scrumpig";
				// String username = "ctran";

				TwitterRequest.getJsonpRequest(url + username.getValue() + ".json");
			}
		});

		this.add(username);

		this.add(userButton);
	}
}
